﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Guedes_Library;
using MySql.Data;

public partial class familyHome : System.Web.UI.MasterPage
{
    List<banner> data;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Repeater1.DataSource = this.GetBanner();
            Repeater1.DataBind();

        }
    }
    
    protected List<banner> GetBanner()
    {
        
       using (guedesEntities _db = new guedesEntities())
        {
            data = (from p in _db.banner
                    orderby p.ID
                    select p).Take(5).ToList();
        }
        return data;
        
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Image bannerImg = (Image)e.Item.FindControl("ImgBan");
        bannerImg.ImageUrl = ResolveClientUrl("~/File/"+ (e.Item.DataItem as banner).Img_Banner);

    }
}
